package cc.geguol.meta;

import org.junit.Test;

import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

/**
 * 作者  Administrator
 * 时间  2017/2/14 13:20
 * 文件  JDBCDemo
 * 描述
 */
public class MetaDataDemo {
	private String url = "jdbc:mysql://localhost:3306/demo";
	private String user = "root";
	private String password = "root";

	/**
	 * @throws ClassNotFoundException
	 * @throws SQLException
	 * 主要是用来做封装orm
	 * 基本上用不到
	 */
	@Test
	public void test2() throws ClassNotFoundException, SQLException {
		Class.forName("com.mysql.jdbc.Driver");

		Connection conn = DriverManager.getConnection(url, user, password);
		Statement cs = conn.createStatement();

		DatabaseMetaData md = conn.getMetaData();
		md.getUserName();
		md.getURL();
//		关闭连接
		cs.close();
		conn.close();
	}
}
